package org.liushengpei.com.controller;

import org.liushengpei.com.service.IAdministrationService;
import org.liushengpei.com.util.result.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 账号管理
 */
@RestController
@RequestMapping(value = "/administration")
public class AdministrationController {

    @Autowired
    private IAdministrationService administrationService;

    /**
     * 获取账号登录时长和上次登录时间
     *
     * @param id 用户id
     */
    @GetMapping(value = "/getLoginData")
    public ResultData getLoginData(@RequestParam(value = "id") String id) {
        return ResultData.success(administrationService.getLoginData(id));
    }

    /**
     * 退出登录
     *
     * @param id 用户id
     */
    @GetMapping(value = "/exitLogin")
    public ResultData exitLogin(@RequestParam(value = "id") String id) {
        return ResultData.success(administrationService.exitLogin(id));
    }

    /**
     * 注销账号
     *
     * @param id 用户id
     */
    @GetMapping(value = "/logOffAccount")
    public ResultData logOffAccount(@RequestParam(value = "id") String id) {
        return ResultData.success(administrationService.logOffAccount(id));
    }

}
